/**
 * Created by dinghh on 2018-7-11.
 */
angular.module('MetronicApp').controller('RecognitionDetailController',
    ['$rootScope', '$scope', '$state', '$uibModal', 'toastr', '$location', '$stateParams', 'FileStorageService', 'RecognitionDetailService',
        function ($rootScope, $scope, $state, $uibModal, toastr, $location, $stateParams, FileStorageService, RecognitionDetailService) {
            $scope.$on('$viewContentLoaded', function () {
                App.initAjax();
                $rootScope.settings.layout.pageBodySolid = true;
                $rootScope.settings.layout.pageSidebarClosed = false;
            });


            //echarts图
            $scope.counterfeitIndex0 = 0;
            $scope.testPentacleId = 1;
            $scope.testBarId = 2;

            $scope.type = $stateParams.type;
            $scope.index = $stateParams.index;

            if (!$scope.type) {
                $scope.type = "modelManagement";
            }
            if ($scope.index) {
                $scope.index = parseInt($scope.index);
                switch ($scope.index) {
                    case 1:
                        $scope.modelManagement = true;
                        $scope.recognitionDetail = false;
                        break;
                    case 2:
                        $scope.modelManagement = false;
                        $scope.recognitionDetail = true;
                        break;
                    default:
                        $scope.modelManagement = true;
                        $scope.recognitionDetail = false;
                }
            } else {
                $scope.modelManagement = true;
                $scope.recognitionDetail = false;
            }

            //切换两个页面
            $scope.changePage = function (index) {
                switch (index) {
                    case 1:
                        $scope.modelManagement = true;
                        $scope.recognitionDetail = false;
                        $state.go('modelManagementList');
                        // $location.path("/decisionAnalysis/falseRecognition/modelManagement/list.html");
                        break;
                    case 2:
                        $scope.modelManagement = false;
                        $scope.recognitionDetail = true;
                        $state.go('recognitionDetail', {type: "recognitionDetail", index: 2});
                        // $location.path("/decisionAnalysis/falseRecognition/recognitionDetail/list.html");
                        break;
                    default:
                        $scope.modelManagement = true;
                        $scope.recognitionDetail = false;
                }
            };

            //获取公司数据
            RecognitionDetailService.list().$promise.then(function (result) {
                if ("success" == result.status) {
                    $scope.companies = result.data;
                    $scope.totalElements = $scope.companies.length;
                    $scope.size = 3;
                } else {
                    for (var index in result.errors) {
                        toastr.error(result.errors[index].errmsg, "数据信息获取失败");
                    }
                }
            });

            //关注或取消关注
            $scope.selected = [];
            $scope.follow = function ($index, company) {
                $scope.selected.push(company);
                company.isFollow = !company.isFollow;
            };

            //查看详情
            $scope.view = function (company) {
                $state.go('recognitionCompanyDetail', {id: company.id, type: "recognitionDetail", index: 2});
            };

        }
    ]
);
/**
 * Created by dinghh on 2018-7-11.
 */
angular.module('MetronicApp').controller('RecognitionDetailController',
    ['$rootScope', '$scope', '$state', '$uibModal', 'toastr', '$location', '$stateParams', 'FileStorageService', 'RecognitionDetailService',
        function ($rootScope, $scope, $state, $uibModal, toastr, $location, $stateParams, FileStorageService, RecognitionDetailService) {
            $scope.$on('$viewContentLoaded', function () {
                App.initAjax();
                $rootScope.settings.layout.pageBodySolid = true;
                $rootScope.settings.layout.pageSidebarClosed = false;
            });


            //echarts图
            $scope.counterfeitIndex0 = 0;
            $scope.testPentacleId = 1;
            $scope.testBarId = 2;

            $scope.condition = {};

            $scope.tabItemList = [
                {
                    "name": "模型管理",
                    "router": "modelManagementList",
                    "selected": false
                },
                {
                    "name": "污染源数据造假识别",
                    "router": "recognitionDetail",
                    "selected": true
                }
            ];

            //获取公司数据
            RecognitionDetailService.list().$promise.then(function (result) {
                if ("success" == result.status) {
                    $scope.companies = result.data;
                    $scope.totalElements = $scope.companies.length;
                    $scope.size = 3;
                } else {
                    for (var index in result.errors) {
                        toastr.error(result.errors[index].errmsg, "数据信息获取失败");
                    }
                }
            });

            //关注或取消关注
            $scope.selected = [];
            $scope.follow = function ($index, company) {
                $scope.selected.push(company);
                company.isFollow = !company.isFollow;
            };

            //查看详情
            $scope.view = function (company) {
                $state.go('recognitionCompanyDetail', {id: company.id, type: "recognitionDetail", index: 2});
            };

        }
    ]
);
